QuickTime 2.1 provides additional functionality for media handlers. By way of modifier tracks, media handlers can now send their data to another media handler rather than presenting their media directly. See "Modifier Tracks" earlier in this chapter for a complete discussion of this feature.
To create a movie with modifier tracks, first you create a movie with all the desired tracks, then you create the modifier track. To link the modifier tracks to the track that it will modify, use the existing AddTrackReference function as shown in the following code:
long addedIndex;
AddTrackReference(aVideoTrack, aModifierTrack, kTrackModifierReference, &addedIndex);
The reference doesn't completely describe the modifier track's relationship to the track it modifies. Instead, the reference simply tells the modifier track to send its data to the specified track. The receiving track doesn't know what it should do with that data. A single track may also be receiving data from more than one modifier track.
To describe how each modifier input should be used, each track's media also has an input map. The media's input map describes how the data being sent to each input of a track should be interpreted by the receiving track. After creating the reference, it is necessary to update the receiving track's media input map. When AddTrackReference is called, it returns the index of the reference added. That index is the index of the input which needs to be described in the media input map. If the modifier track created above contained regions to change the shape of the video track, the following code updates the input map appropriately:
QTAtomContainer inputMap;
QTAtom inputAtom;
OSType inputType;
Media aVideoMedia = GetTrackMedia(aVideoTrack);
GetMediaInputMap (aVideoMedia, &inputMap);
QTInsertChild(inputMap, kParentAtomIsContainer, kTrackModifierInput,
addedIndex, 0,0, nil, &inputAtom);
inputType = kTrackModifierTypeClip;
QTInsertChild (inputMap, inputAtom, kTrackModifierType, 1, 0,
sizeof(inputType), &inputType, nil);
SetMediaInputMap(aVideoMedia, inputMap);
QTDisposeAtomContainer(inputMap);
The media input map allows you to store additional information for each input. In the preceding example, only the type of the input is specified. In other types of references, you may need to specify additional data.
When a modifier track is playing an empty track edit, is disabled or deleted, all receiving tracks are notified that the track input is inactive. When an input becomes inactive, it resets to its default value. For example, if a track was receiving data from a clip modifier track and that input becomes inactive, the shape of the track will revert to the shape it would have if there were no clip modifier track.